import jwt
def get_param(request, name):
    return request.values.get(name)

def get_header(request, name):
    return request.headers[name]


def get_username_by_token(token):
    decode_jwt = jwt.decode(token, 'sadasd', algorithms=['HS256'],
                            options={"verify_signature": False})
    return decode_jwt['username']

def get_username_by_request(request):
    decode_jwt = jwt.decode(get_header(request, 'X-Auth-Token'), 'sadasd', algorithms=['HS256'],
                            options={"verify_signature": False})
    return decode_jwt['username']

